//
//  UILabel+Extension.swift
//  XinLangWeiBo
//
//  Created by mac on 15/11/5.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit
extension UILabel{
/// 便利构造函数
///
/// - parameter title:    title
/// - parameter fontSize: fontSize，默认 14 号字
/// - parameter color:    color，默认深灰色
///
/// - returns: UILabel
/// 参数后面的值是参数的默认值，如果不传递，就使用默认值

convenience init(title: String,
    fontSize: CGFloat = 14,
    color: UIColor =
    UIColor.darkGrayColor(),
    screenInset: CGFloat = 0
    ){
    
    self.init()
    text = title
    textColor = color
    font = UIFont.systemFontOfSize(fontSize)
    numberOfLines = 0
    
        if screenInset == 0{
            textAlignment = NSTextAlignment.Center
        }else{
            
            //设置换行宽度
            preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * screenInset
            textAlignment = .Left
            
        }
    
    sizeToFit() 
    
}

//let label = UILabel()
//label.text = "关注一些人，回这里看看有什么惊喜关注一些人，回这里看看有什么惊喜"
//label.textColor = UIColor.darkGrayColor()
//label.font = UIFont.systemFontOfSize(14)
//label.numberOfLines = 0
//label.textAlignment = NSTextAlignment.Center
//
//return label
}